package com.zbkj.service.service;

import com.zbkj.common.vo.ChunkUploadVo;
import com.zbkj.common.vo.ChunkUploadResultVo;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * 大文件上传服务接口
 * +----------------------------------------------------------------------
 * | CRMEB [ CRMEB赋能开发者，助力企业发展 ]
 * +----------------------------------------------------------------------
 * | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
 * +----------------------------------------------------------------------
 * | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权
 * +----------------------------------------------------------------------
 * | Author: CRMEB Team <admin@crmeb.com>
 * +----------------------------------------------------------------------
 */
public interface BigFileUploadService {
    
    /**
     * 检查文件是否已存在
     * @param identifier 文件唯一标识符
     * @return ChunkUploadResultVo
     */
    ChunkUploadResultVo checkFileExists(String identifier);
    
    /**
     * 上传文件分片
     * @param file 分片文件
     * @param chunkUploadVo 分片上传参数
     * @return ChunkUploadResultVo
     * @throws IOException
     */
    ChunkUploadResultVo uploadChunk(MultipartFile file, ChunkUploadVo chunkUploadVo) throws IOException;
    
    /**
     * 合并文件分片
     * @param chunkUploadVo 分片上传参数
     * @return ChunkUploadResultVo
     * @throws IOException
     */
    ChunkUploadResultVo mergeChunks(ChunkUploadVo chunkUploadVo) throws IOException;
    
    /**
     * 获取上传进度
     * @param identifier 文件唯一标识符
     * @return ChunkUploadResultVo
     */
    ChunkUploadResultVo getUploadProgress(String identifier);
    
    /**
     * 取消上传，清理临时文件
     * @param identifier 文件唯一标识符
     */
    void cancelUpload(String identifier);
} 